#ifndef ARTICLEWIDGET_H
#define ARTICLEWIDGET_H

#include <QWidget>
#include <QAbstractScrollArea>
#include <QScrollArea>
#include "ui_ArticleWidget.h"
#include "lib/topic.h"

class ArticleWidget:public QWidget, public Ui::ArticleWidget{
    Q_OBJECT
    private:
	Article * source;
    public:
	ArticleWidget(Article * article = 0, QWidget * parent = 0);
	void setSource(Article * article);
    public slots:
	void refresh(Article * article = 0);
};

class ArticleList:public QWidget{
    Q_OBJECT
    public:
	enum ArticleStatus{
	    Expanded = 0,
	    Collapsed = 1
	};
    private:
	static int KeepCount;
	int index;
	Topic * topic;
	QList<ArticleWidget *> list;
	QVBoxLayout * layout;
    public:
	ArticleList(QWidget * parent = 0);
	Topic * getTopic() const;
	/*
	* Insert a article to a ArticleList(= scroll area).
	*/
	void insertArticle(Article * article, ArticleList::ArticleStatus status
			= ArticleList::Expanded);
    public slots:
	/*
	* Hide all the article widgets.
	* Probably delete those index > KeepCount to make memery free.
	*/
	void reset();
	void refresh(Article * article = 0);
	void update(int code);
	void setTopic(Topic * newTopic = 0);
};

#endif
